//
//  ShopMuaCell.m
//  AppMua3
//
//  Created by duong nguyen on 8/27/12.
//  Copyright (c) 2012 uit. All rights reserved.
//

#import "ShopMuaCell.h"

@implementation ShopMuaCell
@synthesize shopName,levelImageView,productImageView,productName,productPrice;
@synthesize imvLike,imvComment,like,comment,viewgroup1,viewGroup2;
@synthesize btLike,btMore,btComment;

-(id) init{
    [super init];

    
    return self;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.levelImageView=[[UIImageView alloc]init];
        self.shopName=[[UILabel alloc]init];
        self.productName=[[UILabel alloc]init];
        self.productImageView=[[UIImageView alloc]init];
        self.productPrice=[[UILabel alloc]init];
        self.viewgroup1=[[UIView alloc]init];
        self.btLike=[[UIButton alloc]init];
        self.btComment=[[UIButton alloc]init];
        self.btMore=[[UIButton alloc]init];
        
        if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) {
            [self initIphoneViews];
        }else {
            [self initIpadViews];
        }
       
         self.selectionStyle=UITableViewCellSelectionStyleNone;
        [self setBackgroundColor:[UIColor whiteColor]];
        [self setBackgroundView:nil];
        
//        [self.contentView addSubview:shopName];
//        [self.contentView addSubview:levelImageView];
        [self.contentView addSubview:productImageView];
        [self.contentView addSubview:productName];
        [self.contentView addSubview:productPrice];

//        [self.contentView addSubview:self.viewgroup1];
//        [self.contentView addSubview:self.like];
//        [self.contentView addSubview:self.comment];
        [self.contentView addSubview:self.btLike];
        [self.contentView addSubview:self.btComment];
//        [self.contentView addSubview:self.btMore];
        
        
    }
    return self;
}

-(void) initIphoneViews{
   
    // Initialization code
    [levelImageView setFrame: CGRectMake(-2, 7, 25, 24)];
    [self.levelImageView setImage:[UIImage imageNamed:@"vip_iphone.png"]];
    //
    [self.shopName setFrame:CGRectMake(31, 12, 200, 15)];
    [self.shopName setFont:[UIFont fontWithName:@"arial.ttf" size:12]];
    [self.shopName setTextColor:[UIColor colorWithRed:(0/255.f) green:(161/255.f) blue:(228/255.f) alpha:1]];
    self.shopName.textAlignment=UITextAlignmentLeft;
    [self.shopName setUserInteractionEnabled:YES];
    
    
    // product images.
    [self.productImageView setFrame:CGRectMake(4, 37, 300, 230)];
    self.productImageView.contentMode=UIViewContentModeScaleAspectFit;
    
    // product name.
    [self.productName setFrame:CGRectMake(5, 7, 300, 25)];
   
    [self.productName setTextColor:[UIColor colorWithRed:(0/255.f) green:(161/255.f) blue:(228/255.f) alpha:1]];
    [self.productName setFont:[UIFont systemFontOfSize:12]];
    [self.productName setUserInteractionEnabled:NO];
    
    
    // Price.
    [self.productPrice setFrame:CGRectMake(6, 289, 200, 20)];
    [self.productPrice setFont:[UIFont systemFontOfSize:20]];
    [self.productPrice setTextColor:[UIColor redColor]];
    
    //
    [self.viewgroup1 setFrame:CGRectMake(0, 310, 320, 30)];
    [self.viewgroup1 setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"acc_bar.png"]]];
    
    self.like=[[UILabel alloc]initWithFrame:CGRectMake(23, 320, 20, 12)];
    [self.like setFont:[UIFont systemFontOfSize:11]];
    //[self.like setFont:[UIFont fontWithName:@"arial.ttf" size:11]];
    [self.like setText:@"12"];
    
    self.comment=[[UILabel alloc]initWithFrame:CGRectMake(68, 320, 20, 12)];
    [self.comment setFont:[UIFont systemFontOfSize:11]];
    //[self.comment setFont:[UIFont fontWithName:@"arial.ttf" size:11]];
    [self.comment setText:@"12"];
    
    // Add Button like
    [self.btLike setFrame:CGRectMake(172, 285, 59, 25)];
    [self.btLike setBackgroundImage:[UIImage imageNamed:@"bt_like.png"] forState:UIControlStateNormal];
    
    [self.btComment setFrame:CGRectMake(234, 285,73, 25)];
    [self.btComment setBackgroundImage:[UIImage imageNamed:@"bt_comment.png"] forState:UIControlStateNormal];
    
    [self.btMore setFrame:CGRectMake(245, 313, 59, 25)];
    [self.btMore setBackgroundImage:[UIImage imageNamed:@"bt_more.png"] forState:UIControlStateNormal];
}

-(void) initIpadViews{
    [self.levelImageView setFrame:CGRectMake(0, 1, 64, 64)];
    [self.levelImageView setImage:[UIImage imageNamed:@"vip_ipad.png"]];
    self.levelImageView.contentMode=UIViewContentModeScaleAspectFill;
    [self.levelImageView setBackgroundColor:[UIColor redColor]];
    // ShopName label
    self.shopName=[[UILabel alloc]initWithFrame:CGRectMake(75, 29, 700, 24)];
    [self.shopName setTextColor:[UIColor colorWithRed:(0/255.f) green:(161/255.f) blue:(228/255.f) alpha:1]];
    self.shopName.textAlignment=UITextAlignmentLeft;
    [self.shopName setUserInteractionEnabled:YES];
    [self.shopName setFont:[UIFont systemFontOfSize:22]];
    // Product image
    self.productImageView=[[UIImageView alloc]initWithFrame:CGRectMake(12, 79, 724, 490)];
    self.productImageView.contentMode=UIViewContentModeScaleAspectFit;
    [self.productName setBackgroundColor:[UIColor redColor]];
    
    // Product name
    [self.productName setFrame:CGRectMake(12, 29, 724, 24)];
    [self.productName setTextColor:[UIColor blackColor]];
    [self.productName setFont:[UIFont systemFontOfSize:20]];
    
    // Product price
    self.productPrice=[[UILabel alloc]initWithFrame:CGRectMake(12, 620, 300, 24)];
    [self.productPrice setTextColor:[UIColor redColor]];
    [self.productPrice setFont:[UIFont systemFontOfSize:26]];
    
    // View Group 1
    [self.viewgroup1 setFrame:CGRectMake(0, 667, 768, 64)];
    [self.viewgroup1 setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"acc_bar_ipad.png"]]];
    
    // Add Button like
    [self.btLike setFrame:CGRectMake(258, 615, 139, 54)];
    [self.btLike setBackgroundImage:[UIImage imageNamed:@"bt_like_ipad.png"] forState:UIControlStateNormal];
    
    [self.btComment setFrame:CGRectMake(405, 674,176, 54)];
    [self.btComment setBackgroundImage:[UIImage imageNamed:@"bt_comment_ipad.png"] forState:UIControlStateNormal];
    
    [self.btMore setFrame:CGRectMake(589, 674, 139, 54)];
    [self.btMore setBackgroundImage:[UIImage imageNamed:@"bt_more_ipad.png"] forState:UIControlStateNormal];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    
}


-(void)dealloc{
    [super dealloc];
    [self.levelImageView release];
    [self.shopName release];
    [self.productName release];
    [self.productPrice release];
    [self.productImageView release];
    [self.btMore release];
    [self.btComment release];
    [self.btLike release];
}
@end
